package cn.chenxiejia;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/***
 * @program: maven
 * @ClassName: File6
 * @Description: 文件的复制
 * @Author: chenxiejia
 * @Date: 2022/1/18 20:13
 * @version : V1.0
 */
public class File6 {
    public static void main(String[] args) {
        String s = "E:/aa.txt";
        String ss = "D:/aa.txt";
        try (var fio = new FileOutputStream(ss); var fiu = new FileInputStream(s)) {
            //文件复制功能
            // fiu.transferTo(fio);
            //循环复制
            byte[] buf = new byte[1024];
            int len = 0;
            while ((len = fiu.read(buf)) != -1) {
                fio.write(buf);
            }
            //一次全部复制
            //fio.write(fiu.readAllBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
